<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">

		<link href="css/mui.min.css" rel="stylesheet" />
		<link href="css/mui.indexedlist.css" rel="stylesheet" />
		<link href="style/fjol_style.css" rel="stylesheet" />
		<link rel="stylesheet" type="text/css" href="style/xol_style.css"/>
		<style>
			html,
			body {
				height: 100%;
				overflow: hidden;
			}
		</style>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav newbgRed">
		    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
		    <h1 class="mui-title">选择地区</h1>
		</header>
		<div class="mui-content">
			<!--<div class="mui-group-list-bar" style="height: 100%;">-->
				<!-- 侧边字母 -->
				<!--<div id="cityLetter">
					
				</div>		-->
			<!--</div>-->
			<div class="mui-scroll-wrapper" id="refreshContainer" style="top:50px;">
			    <div class="mui-scroll">
			        <!--这里放置真实显示的DOM内容-->
			        <p>订阅城市</p>
					<ul class="mui-table-view mb10">
				        <li class="mui-table-view-cell" id="curCity">
				                泉州市
				        </li>
				   </ul>
				    
			        <ul class="mui-table-view cities-list" id="citiesList">
		                
		          </ul>
			    </div>
			</div>
			
		</div>
	</body>
	<script src="js/mui.min.js"></script>
		<script src="js/jquery-2.1.0.js"></script>
		<script src="js/jQuery.Hz2Py-min.js"></script>
		<script src="js/fj_public_js.js"></script>		
		<script src="js/md5.js"></script>
		<script src="js/enum.util.js"></script>
		<script src="js/generalUtil.js"></script>
		<script src="js/fj_base_data.js"></script>
		<script src="js/network.js"></script>
		<script src="js/fj_area_util.js"></script>
	<script type="text/javascript" charset="utf-8">
		mui.init();
			
		function plusReady(){

    plus.nativeUI.showWaiting();//这里是开始显示原生等待框

 plus.nativeUI.closeWaiting();//这里监听页面是否加载完毕，完成后关闭等待框
 
			//父页面传参
			var wv = plus.webview.currentWebview();
			var parentId = wv.parentId;
			var currentCity = wv.currentCity;
			var identId = wv.identId;	//noChooseCity为不限，其余对应int
//			console.log(identId);
			document.querySelector('#curCity').innerHTML = currentCity;	//当前城市
			
			var showCityList = document.getElementById('citiesList');
			var net = fjNetwork;
				getBaseData(net);
				var areaUtil = areaUtils;
				areaUtil.setNetworkClient(net);
				//获取城市列表
				var areaLevelCity = 2;
				
				areaUtil.getAreaListByLevel(areaLevelCity,function(){
					
					var currentCity = areaUtil.getCurrentCity();

					if(currentCity==null){
						areaUtil.setCurrentCityByCityName('泉州市');
					}
					
				});	
					
					areaUtil.getChildAreaListWithParentId(identId,false,function(data){
					
					var childAreaList = areaUtil.getCurrentCityChileAreaList();
//					console.log(JSON.stringify(data));

					var listLi = new Array();
					
//					var pushCities = sortCity(data);
					listLi.push('<li class="mui-table-view-cell citiesLi" id="0">不限</li>');
					
//					for (item in pushCities) {
//		//				console.log(typeof(pushCities[item]));
//						if(typeof(pushCities[item])=='string'){
//							listLi.push('<li class="mui-table-view-cell citiesLi">'+pushCities[item]+'</li>');
//						}else{
//							listLi.push('<li class="mui-table-view-cell citiesLi" id="'+pushCities[item].identId+'">'+pushCities[item].areaName+'</li>');
//						}
//						
//					}
					for (i in data) {
						listLi.push('<li class="mui-table-view-cell citiesLi" id="'+data[i].identId+'">'+data[i].areaName+'</li>');
					}
					showCityList.innerHTML = listLi.join(''); // 使用join生成最终字符串   
				
				

	
					//	console.log(parentId);
						
						(function($){
						   	function getElement(obj){
						   		_obj = '#'+obj;
						   		return $(_obj);
						   	}
						
//							var domTop=[];
//							for (var i=0;i<$('.citiesLi p').length; i++) {
//								$('#cityLetter').append('<a>'+$('.citiesLi p').eq(i).attr('id')+'</a>');
//								domTop[i] = $('.citiesLi p').eq(i).offset().top;
//								
//						
//							}
//							
//						   	$('#cityLetter a').each(function(){
//						   		$(this).click(function(){
//						   			var letterId = $(this).text();
//						   			var letterIdx = $(this).index();
//					
//									mui('#refreshContainer').scroll().scrollTo(0,-domTop[letterIdx]+60);
//						
//						   		});
//						   	});
						   	
						   	$('.citiesLi').each(function(){
						   		$(this).click(function(){
					
						   			if($(this).children().length==1){
					
						   				return false;
						   			}else{
						   				
						   				var _cityName = $(this).text();
						   				var _cityId = $(this).attr('id');
						   				if(_cityId == 0){
						   					_cityName = areaUtil.getCurrentCity().areaName;
						   				}
						   				if(parentId=='fj_subscribe'){
						   					indexPage = plus.webview.getWebviewById('fj_subscribe');
							   				
						   				}else if(parentId == 'xol_index'){
//											indexPage = plus.webview.getWebviewById('xol_index');
											indexPage = plus.webview.currentWebview().opener();
										}
						   				mui.fire(indexPage,'getchildCity',{		//自定义函数 返回首页城市
						   					cityName:_cityName,
						   					cityAreaIdentId:_cityId
						   				});
						   				
						   				mui.back();
						   			}
						   		})
						   	})
					   })(jQuery);
					
						});

				
}
document.addEventListener("plusready",plusReady,false);



   


	</script>

</html>